<?php
namespace Entity;

class Player
{
    private $id         = NULL;
    private $ip         = NULL;
    private $socket     = NULL;
    private $name       = NULL;
    private $next_step  = NULL;
    private $state      = NULL;
    
    public function __construct($id, $ip, $socket)
    {
        if ( ! $id)
            throw new \InvalidArgumentException('id');
        if ( ! $ip)
            throw new \InvalidArgumentException('ip');
        if ( ! $socket)
            throw new \InvalidArgumentException('socket');

        $this->id           = $id;
        $this->ip           = $ip;
        $this->socket       = $socket;
        $this->next_step    = FALSE;
        $this->state        = States::FREE;
    }

    public function getId()
    {
        return $this->id;
    }

    public function getIp()
    {
        return $this->name;
    }

    public function getSocket()
    {
        return $this->socket;
    }

    public function setName($name)
    {
        if ( ! $name)
            throw new \InvalidArgumentException('name');
        $this->name = $name;
    }
    
    public function getName()
    {
        return $this->name;
    }

    public function setState($state)
    {
        $this->state = $state;
    }

    public function getState()
    {
        return $this->state;
    }

    public function stInGame()
    {
        return ($this->state === States::INGAME ? TRUE : FALSE);
    }

    public function stGameDecision()
    {
        return ($this->state === States::GAME_DECISION ? TRUE : FALSE);
    }

    public function stFree()
    {
        return ($this->state === States::FREE ? TRUE : FALSE);
    }
    
    public function setNextStep($my_next_step)
    {
        $this->next_step = $my_next_step;
    }
    
    public function isHisTurn()
    {
        return $this->next_step;
    }
}

/**
 * States
 */
class States
{
    const FREE              = '01';
    const GAME_DECISION     = '02';
    const INGAME            = '03';
}

#eof
